<div class="col-sm-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>添加用户</h5>

        </div>
        <div class="ibox-content">
            <form class="form-horizontal m-t from" id="modifyPasswodForm" action="/seller/modify/password" method="post">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 control-label">原密码：</label>
                    <div class="col-sm-8 col-xs-12">
                        <input id="username" name="oldPassword" class="form-control" type="password" aria-required="true" aria-invalid="true" class="error">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请输入您的原密码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 control-label">密码：</label>
                    <div class="col-sm-8 col-xs-12">
                        <input id="password" name="password" class="form-control" type="password">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请输入您的新密码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 control-label">确认密码：</label>
                    <div class="col-sm-8 col-xs-12">
                        <input id="confirm_password" name="confirmPassword" class="form-control" type="password">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的新密码</span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-3">
                        <button class="btn btn-primary submit-btn" type="submit">提交</button>
                        <button type="button" class="btn btn-warning" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(".submit-btn").on("click", function () {
        var oldPassword = $("#modifyPasswodForm").find("input[name='oldPassword']");
        var password = $("#modifyPasswodForm").find("input[name='password']");
        var confirmPassword = $("#modifyPasswodForm").find("input[name='confirmPassword']");

        if (oldPassword.val() == '' || oldPassword.val().length < 6){
            oldPassword.siblings('span').text('密码不能为空或者长度不能小于6').parents('.form-group').addClass('has-error');
            return false;
        }
        oldPassword.siblings('span').text('').parents('.form-group').removeClass('has-error');

        if (password.val() == '' || password.val().length < 6){
            password.siblings('span').text('密码不能为空或者长度不能小于6').parents('.form-group').addClass('has-error');
            return false;
        }
        password.siblings('span').text('').parents('.form-group').removeClass('has-error');

        if (confirmPassword.val() == '' || confirmPassword.val().length < 6){
            confirmPassword.siblings('span').text('密码不能为空或者长度不能小于6').parents('.form-group').addClass('has-error');
            return false;
        }
        confirmPassword.siblings('span').text('').parents('.form-group').removeClass('has-error');

        if (password.val() != confirmPassword.val()){
            password.siblings('span').text('新密码和确认密码必须相等').parents('.form-group').addClass('has-error');
            confirmPassword.siblings('span').text('新密码和确认密码必须相等').parents('.form-group').addClass('has-error');
            return false;
        }
        modalFormSubmit($("#modifyPasswodForm"));
        return false;
    });

</script>
